package com.ego.framework.utils;


import com.ego.system.domain.User;

/**
 * 通过ThreadLocal的形式，存储用户的数据
 */
public class UserHolder {
    
    private static ThreadLocal<User> Users = new ThreadLocal<>();

    //向当前线程存储数据
    public static void set(User User) {
        Users.set(User);
    }

    //从当前线程获取数据
    public static User getUser() {
        return Users.get();
    }

    public static void remove() {
        Users.remove();
    }

//    //获取当前用户的id
    public static Integer getUserId() {
        return Users.get().getId();
    }
}
